<template>
  <div class="firstsbbLeft">
    <s-title text="统计组客流统计" :btnshow="false" />
    <div id="firstsbbLeftChart"></div>
  </div>
</template>

<script>
import sTitle from "../../common/sTitle.vue";
import axios from "axios";
export default {
  name: "firstsbbLeft1",
  components: {
    sTitle
  },
  data() {
    return {
      comps: [],
      ls: [
        {
          px: 6,
          ny: "2021-04",
          yps: 3,
          rps: 0,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        },
        {
          px: 5,
          ny: "2021-05",
          yps: 0,
          rps: 4,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        },
        {
          px: 4,
          ny: "2021-06",
          yps: 0,
          rps: 0,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        },
        {
          px: 3,
          ny: "2021-07",
          yps: 0,
          rps: 0,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        },
        {
          px: 2,
          ny: "2021-08",
          yps: 0,
          rps: 0,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        },
        {
          px: 1,
          ny: "2021-09",
          yps: 0,
          rps: 0,
          tjsj: "2021-09-26T19:32:47.000+00:00"
        }
      ],
      warningDataList: [
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 0,
          isDelete: 0,
          holdBase: 0,
          updateTime: "2021-07-27T14:00:59.80332+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "萧县政务中心客流统计",
          warningValue: null,
          id: "b9455734-dd26-41f9-b823-72b0a1e11a43",
          workEndTime: "23:59",
          workStartTime: "00:00"
        },
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 1,
          isDelete: 1,
          holdBase: 0,
          updateTime: "2021-07-19T15:13:03.334535+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "2",
          warningValue: null,
          id: "cb6c0d96-ab1d-40d1-b674-a95c57b1b18e",
          workEndTime: "23:59",
          workStartTime: "00:00"
        },
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 1,
          isDelete: 1,
          holdBase: 0,
          updateTime: "2021-07-19T15:12:47.925327+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "1",
          warningValue: null,
          id: "8f6aed27-d0de-4f17-b046-c7ab2bf85d3e",
          workEndTime: "23:59",
          workStartTime: "00:00"
        },
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 1,
          isDelete: 1,
          holdBase: 0,
          updateTime: "2021-07-19T15:12:25.534323+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "A裙楼南大门-西",
          warningValue: null,
          id: "11e0f6ee-f89c-4d40-aeee-d7f365c2236a",
          workEndTime: "23:59",
          workStartTime: "00:00"
        },
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 1,
          isDelete: 1,
          holdBase: 0,
          updateTime: "2021-07-19T15:12:12.267538+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "A裙楼南大门-东",
          warningValue: null,
          id: "4f787c42-5e1a-46dd-b203-9dec14912ef0",
          workEndTime: "23:59",
          workStartTime: "00:00"
        },
        {
          area: null,
          regionPath:
            "@root000000@27044a4f-df9a-4b9c-bfe0-e5d9df9894a9@05ef4526-060e-4131-aa27-0221ae6505b3@",
          warningSwitch: 0,
          statType: 0,
          isDelete: 1,
          holdBase: 0,
          updateTime: "2021-07-19T15:02:09.148106+08:00",
          thirdPartCode: null,
          type: 1,
          earlyWarningValue: null,
          regionId: "05ef4526-060e-4131-aa27-0221ae6505b3",
          name: "客流统计",
          warningValue: null,
          id: "0d0580a2-cd66-479d-b14f-ec354f93b648",
          workEndTime: "23:59",
          workStartTime: "00:00"
        }
      ]
    };
  },
  mounted() {
    //     axios.get(this.$serverIp + "getQsfx").then((res) => {

    //       //res = this.ls;
    //        var echartData = { data1: [], data2: [],data3:[] };
    //       for(var i=0;i<res.data.length;i++){
    // echartData.data1.push(res.data[i].ny);
    // echartData.data2.push(res.data[i].yps);
    // echartData.data3.push(res.data[i].rps);
    //       }
    //       // var echartData = { xData: [], yData: [] };
    //       // echartData.yData[0] = [];
    //       // echartData.yData[1] = [];
    //       // for (let i = 0; i < res.data.length; i++) {
    //       //   echartData.xData.push(res.data[i].ny);
    //       //   echartData.yData[0].push(res.data[i].yps);
    //       //   echartData.yData[1].push(res.data[i].rps);
    //       // }
    //       this.setEchartHandle(echartData);
    //     });
    //     //this.setEchartHandle();
    
this.loadIN_OUT();
  },
  methods: {
     async loadIN_OUT(){
          var MultipleStatisticalGroups = [];
    var echartData = { data1: [], data2: [], data3: [] };
     for (var i = 0; i < this.warningDataList.length; i++) {
      //循环获取groupid，作为参数传到后台
      var params = new URLSearchParams();
      params.append("ids", this.warningDataList[i].id);
      params.append("startTime", "2021-08-31T00:00:00+08:00");
      params.append("endTime", "2021-08-31T23:00:00+08:00");
     await axios
        .post(this.$videoIp + "/GetMultipleStatisticalGroups", params)
        .then(res => {
          MultipleStatisticalGroups.push(res.data.data.list);
         
 
        });
    }
     for (var j = 0; j < MultipleStatisticalGroups.length; j++) {
      if (MultipleStatisticalGroups[j].length > 0) {
        for (var k = 0; k < MultipleStatisticalGroups[j].length; k++) {
             
          echartData.data1.push( this.$moment(MultipleStatisticalGroups[j][k].statTime).format(
          "HH-MM"
        ));
          echartData.data2.push(MultipleStatisticalGroups[j][k].flowInNum);
          echartData.data3.push(MultipleStatisticalGroups[j][k].flowOutNum);
        }
      }
    }
    this.setEchartHandle(echartData);
      },
    setEchartHandle(echartData) {
      let _echarts = this.$echarts.init(
        document.getElementById("firstsbbLeftChart"),
        null,
        { devicePixelRatio: 2 }
      );
      let option = {
        backgroundColor: "rgba(255,255,255,0)",
        legend: {
          top: "20",
          x: "center",
          textStyle: {
            fontSize: 16,
            color: "rgba(101, 213, 255, 1)"
          },
          icon:
            "path://M512 881.777778 512 881.777778C716.222629 881.777778 881.777778 716.222629 881.777778 512 881.777778 307.777371 716.222629 142.222222 512 142.222222 307.777373 142.222222 142.222222 307.777371 142.222222 512 142.222222 716.222629 307.777373 881.777778 512 881.777778L512 881.777778ZM512 1024 512 1024C229.230208 1024 0 794.769789 0 512 0 229.230211 229.230208 0 512 0 794.769789 0 1024 229.230211 1024 512 1024 794.769789 794.769789 1024 512 1024L512 1024Z",
          itemWidth: 8, // 设置宽度
          itemHeight: 8, // 设置高度、
          itemGap: 12 // 设置间距
        },
        tooltip: {
          show: true,
          trigger: "axis", //axis , item
          backgroundColor: "RGBA(0, 49, 85, 1)",
          borderColor: "rgba(0, 151, 251, 1)",
          borderWidth: 1,
          borderRadius: 0,
          textStyle: {
            color: "#BCE9FC",
            fontSize: 16,
            align: "left"
          }
        },
        grid: {
          right: "5%",
          top: "20%",
          left: "5%",
          bottom: "5%",
          containLabel: true
        },
        xAxis: {
          type: "category",
          boundaryGap: true,
          data: echartData.data1,
          axisLabel: {
            //坐标轴刻度标签的相关设置。
            interval: 3, //设置为 1，表示『隔一个标签显示一个标签』
            //	margin:15,
            textStyle: {
              color: "#65D5FF",
              fontStyle: "normal",
              fontSize: 10
            }
          },
          axisTick: {
            //坐标轴刻度相关设置。
            show: false
          },
          axisLine: {
            //坐标轴轴线相关设置
            lineStyle: {
              color: "rgba(77, 128, 254, 0.2)"
            }
          },
          splitLine: {
            //坐标轴在 grid 区域中的分隔线。
            show: true,
            lineStyle: {
              color: "rgba(77, 128, 254, 0.2)"
            }
          }
        },
        yAxis: [
          {
            type: "value",
            splitNumber: 3,
            axisLabel: {
              textStyle: {
                color: "#65D5FF",
                fontStyle: "normal",
                fontSize: 16
              }
            },
            axisLine: {
              show: false
            },
            axisTick: {
              show: false
            },
            splitLine: {
              show: true,
              lineStyle: {
                color: "rgba(77, 128, 254, 0.2)"
              }
            }
          }
        ],
        series: [
          {
            name: "入",
            type: "pictorialBar",
            barWidth: "60%",
            stack: "总量",
            label: {
              normal: {
                show: false
              }
            },
            itemStyle: {
              normal: {
                color: {
                  type: "linear",
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [
                    {
                      offset: 0,
                      color: "rgba(0, 151, 251, 1)" // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(0, 34, 66, 0.2)" // 100% 处的颜色
                    }
                  ],
                  globalCoord: false // 缺省为 false
                } //渐变颜色
              }
            },
            symbol:
              "path://M12.000,-0.000 C12.000,-0.000 16.074,60.121 22.731,60.121 C26.173,60.121 -3.234,60.121 0.511,60.121 C7.072,60.121 12.000,-0.000 12.000,-0.000 Z",

            data: echartData.data2
          },
          {
            name: "出",
            type: "pictorialBar",
            barWidth: "60%",
            stack: "总量",
            label: {
              normal: {
                show: false
              }
            },
            itemStyle: {
              normal: {
                color: {
                  type: "linear",
                  x: 0,
                  y: 0,
                  x2: 0,
                  y2: 1,
                  colorStops: [
                    {
                      offset: 0,
                      color: "rgba(48, 236, 166, 1)" // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: "rgba(0, 34, 66, 0.2)" // 100% 处的颜色
                    }
                  ],
                  globalCoord: false // 缺省为 false
                } //渐变颜色
              }
            },
            symbol:
              "path://M12.000,-0.000 C12.000,-0.000 16.074,60.121 22.731,60.121 C26.173,60.121 -3.234,60.121 0.511,60.121 C7.072,60.121 12.000,-0.000 12.000,-0.000 Z",

            data: echartData.data3
          }
        ]
      };

      _echarts.setOption(option);
    }
  }
};
</script>
<style scoped>
#firstsbbLeftChart {
  width: 100%;
  height: 27vh;
  margin-top: 10px;
}
</style>
 